package com.eling.elcms.travel.service.impl;

import com.eling.elcms.travel.model.RoomRegister;
import com.eling.elcms.travel.model.TravelContract;
import com.eling.elcms.travel.model.view.SettlementsResult;
import com.eling.elcms.travel.service.ISettlementsRule;
import com.eling.elcms.travel.util.DateHandlerUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 入住天数消费抵扣规则
 * @author Lina
 * 规则 ：按实际入住天数计抵
 */
@Service
public class DayExpenseServiceImpl implements ISettlementsRule {
	
	private static final Log log = LogFactory.getLog(DayExpenseServiceImpl.class);
	
	@Override
	public SettlementsResult calculate(RoomRegister room, TravelContract contract, Date start, Date end) {
		log.debug("DayExpenseServiceImpl");
		
		SettlementsResult result = new SettlementsResult();
		
		// 获取顾客居住天数:结算日期 - 入住日期
		Integer days = DateHandlerUtil.daysOfTwoDate(start, end);
				
		// 计算抵扣次数，以1人/天为1个抵扣单位
		result.setPiece(days.doubleValue());	
	
		return result;
	}
	
}
